package com.ln.lnzw.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.widget.ImageView;

import com.flyco.tablayout.SlidingTabLayout;
import com.ln.lnzw.R;
import com.ln.lnzw.adapter.NewsFragmentPagerAdapter;
import com.ln.lnzw.app.AppConstant;
import com.ln.lnzw.base.BaseActivity;
import com.ln.lnzw.fragment.ApprovalPublicityFragment;
import com.ln.lnzw.fragment.ConsultingPhoneFragment;
import com.ln.lnzw.view.CustomViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by wuwei on 2018/4/24.
 * 审批公示
 */

public class ApprovalPublicityActivity extends BaseActivity {

    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.SlidingTabLayout)
    com.flyco.tablayout.SlidingTabLayout SlidingTabLayout;
    @BindView(R.id.viewpager)
    CustomViewPager viewpager;
    private NewsFragmentPagerAdapter mAdapetr;
    private List<Fragment> fragmentList;
    private List<String> nameFragment;
    private ApprovalPublicityFragment approvalPublicityFragment;
    private Bundle b;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_approval_publicity);
        ButterKnife.bind(this);
        initData();
        initView();

    }
    private void initData() {
        nameFragment = new ArrayList<>();
        fragmentList = new ArrayList<>();
        nameFragment.add("批准");
        nameFragment.add("不予批准");
        nameFragment.add("公示中");
        nameFragment.add("已撤销");
        for (int i = 0; i < nameFragment.size(); i++) {
                approvalPublicityFragment = new ApprovalPublicityFragment();
                b = new Bundle();
                if (i==0){
                    b.putString("name","pz");
                }else if (i==1){
                    b.putString("name","bypz");
                }else if (i==2){
                    b.putString("name","gsz");
                }else{
                    b.putString("name","ycx");
                }
                approvalPublicityFragment.setArguments(b);
                fragmentList.add(approvalPublicityFragment);
        }

    }
    private void initView() {
        mAdapetr = new NewsFragmentPagerAdapter(activity.getSupportFragmentManager(), fragmentList, nameFragment);
        viewpager.setAdapter(mAdapetr);
        viewpager.setOffscreenPageLimit(2);
        viewpager.setCurrentItem(0, false);
        SlidingTabLayout.setViewPager(viewpager);

    }

    @OnClick(R.id.iv_back)
    public void onViewClicked() {
        finish();
    }
}
